from ..Shell import shell, Shell


### 已舍弃！###


def Tap(x, y):
    shell('input tap', x, y, root=True)


def Swipe(x1, y1, x2, y2, duration=100):
    shell('input swipe', x1, y1, x2, y2, duration, root=True)


def QuickSwipeUp():
    Swipe(600, 1000, 200, 500)


def QuickSwipeDown():
    Swipe(600, 500, 200, 1000)


def Press(x, y, duration=1000):
    shell('input swipe', x, y, x, y, duration, root=True)


# cannot run
def TouchDown(x, y):
    shell('input event DOWN', x, y, root=True)


def TouchUp(x, y):
    shell('input event UP', x, y, root=True)


def TouchMove(x, y):
    shell('input event MOVE', x, y, root=True)


class RootAutomator:
    def __init__(self):
        self._sh = Shell(root=True)

    def __del__(self):
        self._sh.exit()

    def tap(self, x, y):
        self._sh.exec('input tap', x, y)

    def swipe(self, x1, y1, x2, y2, duration=100):
        self._sh.exec('input swipe ', x1, y1, x2, y2, duration)

    def press(self, x, y, duration=1000):
        self._sh.exec('input swipe', x, y, x, y, duration)

    def touchDown(self): pass

    def touchMove(self): pass

    def touchUp(self): pass
